<?php
$sql['admin'] = "DROP TABLE IF EXISTS `{$pre}admin`;
CREATE TABLE `{$pre}admin` (
  `id` int(10) NOT NULL auto_increment,
  `userid` char(20) NOT NULL,
  `username` char(20) NOT NULL COMMENT '姓名',
  `password` char(40) NOT NULL COMMENT '密码',
  `email` char(60) NOT NULL COMMENT '电子邮件',
  `sex` char(10) NOT NULL COMMENT '性别',
  `lasttime` int(10) NOT NULL COMMENT '上次登录时间',
  `lastip` char(20) NOT NULL COMMENT '上次ip',
  `type` tinyint(2) NOT NULL COMMENT '用户类型',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `userid` (`userid`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='管理员表' AUTO_INCREMENT=0 ;
INSERT INTO `{$pre}admin` (`id`, `userid`, `username`, `password`, `email`, `sex`, `lasttime`, `lastip`, `type`) VALUES
(1, '$username', '$username', '$password', 'admin@server.com', '保密', 0, '0', 1);";

$sql['utype'] = "DROP TABLE IF EXISTS `{$pre}utype`;
CREATE TABLE `{$pre}utype` (
  `tid` int(10) NOT NULL auto_increment,
  `name` char(20) NOT NULL,
  `typeid` tinyint(2) NOT NULL,
  PRIMARY KEY  (`tid`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='管理员等级表' AUTO_INCREMENT=0 ;

INSERT INTO `{$pre}utype` (`tid`, `name`, `typeid`) VALUES
(1, '超级管理员', 1),
(2, '读者管理员', 5),
(3, '图书管理员', 10);";
$sql['rtype'] = "DROP TABLE IF EXISTS `{$pre}rtype`;
CREATE TABLE `{$pre}rtype` (
  `tid` int(10) NOT NULL auto_increment,
  `name` char(20) NOT NULL,
  `typeid` tinyint(2) NOT NULL,
  `max_borrow` tinyint(2) NOT NULL COMMENT '最大借书量',
  PRIMARY KEY  (`tid`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='readerrank' AUTO_INCREMENT=0 ;

INSERT INTO `{$pre}rtype` (`tid`, `name`, `typeid`, `max_borrow`) VALUES
(1, '高级读者', 1, 12),
(2, '中级读者', 5, 8),
(3, '初级读者', 10, 5);
";
$sql['reader'] = "DROP TABLE IF EXISTS `{$pre}reader`;
CREATE TABLE `{$pre}reader` (
  `id` int(10) NOT NULL auto_increment,
  `userid` char(20) NOT NULL,
  `username` char(20) NOT NULL COMMENT '姓名',
  `password` char(40) NOT NULL COMMENT '密码',
  `email` char(60) NOT NULL COMMENT '电子邮件',
  `sex` char(10) NOT NULL COMMENT '性别',
  `lasttime` int(10) NOT NULL COMMENT '上次登录时间',
  `lastip` char(20) NOT NULL COMMENT '上次ip',
  `type` tinyint(2) NOT NULL COMMENT '用户类型',
  `total` int(10) NOT NULL COMMENT '用户借书数量',
  `collect` char(200) NOT NULL COMMENT '收藏',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `userid` (`userid`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='读者表' AUTO_INCREMENT=0 ;
";
$sql['btype'] = "DROP TABLE IF EXISTS `{$pre}btype`;
CREATE TABLE `{$pre}btype` (
  `id` int(11) NOT NULL auto_increment COMMENT '图书分类',
  `fid` char(250) NOT NULL COMMENT '父类',
  `value` char(200) NOT NULL COMMENT '分类名称',
  `description` text NOT NULL COMMENT '描述',
  `show` tinyint(1) unsigned NOT NULL default '0' COMMENT '是否在主页显示 0不显示 1 导航栏显示 2只显示在图书分类中',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='图书分类表' AUTO_INCREMENT=0 ;";
$sql['borrow'] = "DROP TABLE IF EXISTS `{$pre}borrow`;
CREATE TABLE `{$pre}borrow` (
  `id` int(10) NOT NULL auto_increment,
  `readerid` int(10) NOT NULL,
  `bookid` int(10) NOT NULL,
  `borrowdate` int(10) NOT NULL,
  `backdate` int(10) NOT NULL,
  `isback` tinyint(1) NOT NULL COMMENT '是否归还',
  `goon` tinyint(1) NOT NULL COMMENT '是否续借',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='借书表' AUTO_INCREMENT=0 ;
";
$sql['book'] = "DROP TABLE IF EXISTS `{$pre}book`;
CREATE TABLE `{$pre}book` (
  `bid` int(10) NOT NULL auto_increment COMMENT '图书id',
  `name` char(100) NOT NULL COMMENT '书名',
  `typeid` mediumint(5) NOT NULL COMMENT '类目',
  `author` char(40) NOT NULL COMMENT '作者',
  `pstore` char(60) NOT NULL COMMENT '出版社',
  `pdate` int(10) NOT NULL COMMENT '出版日期',
  `price` float(8,2) NOT NULL COMMENT '价格',
  `page` mediumint(5) NOT NULL COMMENT '页数',
  `storage` int(10) NOT NULL COMMENT '库存',
  `indate` int(10) NOT NULL COMMENT '入库时间',
  `del` tinyint(1) NOT NULL COMMENT '是否删除',
  `times` int(10) NOT NULL COMMENT '借阅次数',
  `tuijian` tinyint(1) NOT NULL COMMENT '是否推荐',
  `click` int(10) NOT NULL COMMENT '点击数',
  `content` text NOT NULL COMMENT '内容简介',
  `pic` char(200) NOT NULL COMMENT '缩略图',
  PRIMARY KEY  (`bid`)
) ENGINE=InnoDB  DEFAULT CHARSET=gbk COMMENT='图书表' AUTO_INCREMENT=0 ;
";
?>